﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nsf.Samples.RetryActivitySample.Infrastructure.InternalInterfaces;

namespace Nsf.Samples.RetryActivitySample.Infrastructure.Logger
{
    public class Log : ILogger
    {
        #region ILogger Members

        public void Debug(String message)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Debug", message));
            Console.ForegroundColor = oldColor;
        }

        public void Info(String message)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Information", message));
            Console.ForegroundColor = oldColor;
        }

        public void Warning(String message)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Warning", message));
            Console.ForegroundColor = oldColor;
        }

        public void Error(String message)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Error", message));
            Console.ForegroundColor = oldColor;
        }

        public void FatalError(String message)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Fatal", message));
            Console.ForegroundColor = oldColor;
        }

        public void Debug(String message, Exception ex)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Debug", message));
            Console.ForegroundColor = oldColor;
        }

        public void Info(String message, Exception ex)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Information", message));
            Console.ForegroundColor = oldColor;
        }

        public void Warning(String message, Exception ex)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Warning", message));
            Console.ForegroundColor = oldColor;
        }

        public void Error(String message, Exception ex)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Error", message));
            Console.ForegroundColor = oldColor;
        }

        public void FatalError(String message, Exception ex)
        {
            var oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine(String.Format("[{0}] ({1}){2}", DateTime.Now.ToString("hh:MM:ss"), "Fatal", message));
            Console.ForegroundColor = oldColor;
        }

        #endregion
    }
}
